Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
reeft_gps_test
/
REEFTintegrationLog
:
customer_maintain_save-20250624230452.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php //====================================================================================== // // Function: Save a customer // // Programmer: JKJ // Date : 2025-05-07 // // Copyright Reeft A/S (c) - 2025 //====================================================================================== //====================================================================================== // General config //====================================================================================== include "config/config.php"; include "include/REEFT_date_convert.php"; //====================================================================================== // Get input //====================================================================================== if (isset($_REQUEST["mode"])) $mode = $_REQUEST["mode"]; else $mode = ''; if (isset($_REQUEST["data"])) { $data = $_REQUEST["data"]; } else { $data = 'hovsa'; } if ( $mode == '' ) { echo "There's no action....1"; exit; } if ( $mode <> '*add' and $mode <> '*update' and $mode <> '*delete' ) { echo "There's no action....2"; exit; } if ( $data == 'hovsa' ) { echo "There's no data...."; exit; } //====================================================================================== // Convert from JSON //====================================================================================== // Just in case $typeValue = ''; $fk_country = 0; $json = json_decode($data); foreach($json as $obj){ $key = $obj->name; $value = $obj->value; // pk_customer if ( $key == 'modal-input-pk_customer') { $pk_customer = $value; if ( $pk_customer == '' ) $pk_customer = 0; } // cust_active if ( $key == 'modal-input-cust_active') { $cust_active = $value; if ( $cust_active == '' ) $cust_active = ''; } // cust_number if ( $key == 'modal-input-cust_number') { $cust_number = $value; if ( $cust_number == '' ) $cust_number = ''; } // cust_name if ( $key == 'modal-input-cust_name') { $cust_name = $value; if ( $cust_name == '' ) $cust_name = ''; } // cust_group if ( $key == 'modal-input-cust_group') { $cust_group = $value; if ( $cust_group == '' ) $cust_group = ''; } // product if ( $key == 'modal-input-product') { $product = $value; if ( $product == '' ) $product = ''; } // description if ( $key == 'modal-input-description') { $description = $value; if ( $description == '' ) $description = ''; } // integration_version if ( $key == 'modal-input-integration_version') { $integration_version = $value; if ( $integration_version == '' ) $integration_version = ''; } // fileformat_ext_file if ( $key == 'modal-input-fileformat_ext_file') { $fileformat_ext_file = $value; if ( $fileformat_ext_file == '' ) $fileformat_ext_file = ''; } // fileformat_exportterminationfile if ( $key == 'modal-input-fileformat_exportterminationfile') { $fileformat_exportterminationfile = $value; if ( $fileformat_exportterminationfile == '' ) $fileformat_exportterminationfile = ''; } // fileformat_numberdecimalseparator if ( $key == 'modal-input-fileformat_numberdecimalseparator') { $fileformat_numberdecimalseparator = $value; if ( $fileformat_numberdecimalseparator == '' ) $fileformat_numberdecimalseparator = ''; } // fileformat_separator if ( $key == 'modal-input-fileformat_separator') { $fileformat_separator = $value; if ( $fileformat_separator == '' ) $fileformat_separator = ''; } // fileformat_codepage if ( $key == 'modal-input-fileformat_codepage') { $fileformat_codepage = $value; if ( $fileformat_codepage == '' ) $fileformat_codepage = ''; } // program_dir if ( $key == 'modal-input-program_dir') { $program_dir = $value; if ( $program_dir == '' ) $program_dir = ''; } // input_dir if ( $key == 'modal-input-input_dir') { $input_dir = $value; if ( $input_dir == '' ) $input_dir = ''; } // output_dir if ( $key == 'modal-input-output_dir') { $output_dir = $value; if ( $output_dir == '' ) $output_dir = ''; } // error_dir if ( $key == 'modal-input-error_dir') { $error_dir = $value; if ( $error_dir == '' ) $error_dir = ''; } // done_dir if ( $key == 'modal-input-done_dir') { $done_dir = $value; if ( $done_dir == '' ) $done_dir = ''; } // log_dir if ( $key == 'modal-input-log_dir') { $log_dir = $value; if ( $log_dir == '' ) $log_dir = ''; } // export_done_dir if ( $key == 'modal-input-export_done_dir') { $export_done_dir = $value; if ( $export_done_dir == '' ) $export_done_dir = ''; } // import_functions if ( $key == 'modal-input-import_functions') { $import_functions = $value; if ( $import_functions == '' ) $import_functions = ''; } // export_functions if ( $key == 'modal-input-export_functions') { $export_functions = $value; if ( $export_functions == '' ) $export_functions = ''; } // client_id if ( $key == 'modal-input-client_id') { $client_id = $value; if ( $client_id == '' ) $client_id = ''; } // client_secret if ( $key == 'modal-input-client_secret') { $client_secret = $value; if ( $client_secret == '' ) $client_secret = ''; } // organizationId if ( $key == 'modal-input-organizationId') { $organizationId = $value; if ( $organizationId == '' ) $organizationId = ''; } // create_user if ( $key == 'modal-input-create_user') { $create_user = $value; if ( $create_user == '' ) $create_user = ''; } // create_timestamp if ( $key == 'modal-input-create_timestamp') { $create_timestamp = $value; if ( $create_timestamp == '' ) $create_timestamp = ''; } // update_user if ( $key == 'modal-input-update_user') { $update_user = $value; if ( $update_user == '' ) $update_user = ''; } // update_timestamp if ( $key == 'modal-input-update_timestamp') { $update_timestamp = $value; if ( $update_timestamp == '' ) $update_timestamp = ''; } // company_logo_url if ( $key == 'modal-input-company_logo_url') { $company_logo_url = $value; if ( $company_logo_url == '' ) $company_logo_url = ''; } // number_of_exports if ( $key == 'modal-input-number_of_exports') { $number_of_exports = $value; if ( $number_of_exports == '' ) $number_of_exports = ''; } // number_of_imports if ( $key == 'modal-input-number_of_imports') { $number_of_imports = $value; if ( $number_of_imports == '' ) $number_of_imports = ''; } // ERPname if ( $key == 'modal-input-ERPname') { $ERPname = $value; if ( $ERPname == '' ) $ERPname = ''; } // ERPdescription if ( $key == 'modal-input-ERPdescription') { $ERPdescription = $value; if ( $ERPdescription == '' ) $ERPdescription = ''; } // ERPurl if ( $key == 'modal-input-ERPurl') { $ERPurl = $value; if ( $ERPurl == '' ) $ERPurl = ''; } // json_default_path if ( $key == 'modal-input-json_default_path') { $json_default_path = $value; if ( $json_default_path == '' ) $json_default_path = ''; } // json_gps_default_path if ( $key == 'modal-input-json_gps_default_path') { $json_gps_default_path = $value; if ( $json_gps_default_path == '' ) $json_gps_default_path = ''; } // name if ( $key == 'modal-input-name') { $name = $value; if ( $name == '' ) $name = ''; } // group if ( $key == 'modal-input-group') { $group = $value; if ( $group == '' ) $group = ''; } // delete if ( $key == 'confirm-delete-cust_number') { $cust_number_delete = $value; if ( $cust_number_delete == '' ) $cust_number_delete = ''; } } //====================================================================================== // Get session variables //====================================================================================== include "include/getsession.php"; //====================================================================================== // Set language //====================================================================================== include "include/set_language.php"; //====================================================================================== // Set header //====================================================================================== header('Content-Type: application/json;charset=utf-8'); //====================================================================================== // Init fields //====================================================================================== $returnCode = '00'; $returnMsg = 'Alles ist gut'; $entries_found = 1; $sql = ''; $currentDate = date('Y-m-d'); $currentTime = date('H:i:s'); //====================================================================================== // Set database //====================================================================================== $db_name = $CUSTOMER_DATABASE_PATH; //$db_name = 'customer/REEFT_integration.sqlite3'; //====================================================================================== // Start me up... //====================================================================================== $startTime = microtime(true); //====================================================================================== // Check if database file exists //====================================================================================== if (!file_exists($db_name)) { die(json_encode(['error' => "Database file '$db_name' does not exist."])); } //====================================================================================== // Connect to some DB //====================================================================================== $DFT_SQLLITE_IP = $db_name; include "include/db_connect.php"; //====================================================================================== // Set active, token and other default values //====================================================================================== $timestamp = REEFT_current_utc(); //====================================================================================== // Check typeCode //====================================================================================== //====================================================================================== // Create SQL //====================================================================================== if ( $mode == '*update') { $sql = "update reeft_customer set cust_active = $cust_active, cust_number = '$cust_number', cust_name = '$cust_name', cust_group = '$cust_group', product = '$product', description = '$description', integration_version = '$integration_version', fileformat_ext_file = '$fileformat_ext_file', fileformat_exportterminationfile = '$fileformat_exportterminationfile', fileformat_numberdecimalseparator = '$fileformat_numberdecimalseparator', fileformat_separator = '$fileformat_separator', fileformat_codepage = '$fileformat_codepage', program_dir = '$program_dir', input_dir = '$input_dir', output_dir = '$output_dir', error_dir = '$error_dir', done_dir = '$done_dir', log_dir = '$log_dir', export_done_dir = '$export_done_dir', import_functions = '$import_functions', export_functions = '$export_functions', client_id = '$client_id', client_secret = '$client_secret', organizationId = '$organizationId', create_user = '$create_user', create_timestamp = '$create_timestamp', update_user = '$update_user', update_timestamp = '$update_timestamp', company_logo_url = '$company_logo_url', number_of_exports = '$number_of_exports', number_of_imports = '$number_of_imports', ERPname = '$ERPname', ERPdescription = '$ERPdescription', ERPurl = '$ERPurl', json_default_path = '$json_default_path', json_gps_default_path = '$json_gps_default_path' where pk_customer = $pk_customer "; } if ( $mode == '*add') { $sql = "INSERT INTO reeft_customer ( cust_active, cust_number, cust_name, cust_group, product, description, integration_version, fileformat_ext_file, fileformat_exportterminationfile, fileformat_numberdecimalseparator, fileformat_separator, fileformat_codepage, program_dir, input_dir, output_dir, error_dir, done_dir, log_dir, export_done_dir, import_functions, export_functions, client_id, client_secret, organizationId, create_user, create_timestamp, update_user, update_timestamp, company_logo_url, number_of_exports, number_of_imports, ERPname, ERPdescription, ERPurl, json_default_path, json_gps_default_path ) VALUES ( '$cust_active', '$cust_number', '$cust_name', '$cust_group', '$product', '$description', '$integration_version', '$fileformat_ext_file', '$fileformat_exportterminationfile', '$fileformat_numberdecimalseparator', '$fileformat_separator', '$fileformat_codepage', '$program_dir', '$input_dir', '$output_dir', '$error_dir', '$done_dir', '$log_dir', '$export_done_dir', '$import_functions', '$export_functions', '$client_id', '$client_secret', '$organizationId', '$create_user', '$create_timestamp', '$update_user', '$update_timestamp', '$company_logo_url', '$number_of_exports', '$number_of_imports', '$ERPname', '$ERPdescription', '$ERPurl', '$json_default_path', '$json_gps_default_path' )"; } if ( $mode == '*delete') { $dirPath = $DFT_DIR_PATH . "/" . $cust_number_delete; $safetyFile = $dirPath . '/i_must_be_deleted.txt'; if (is_dir($dirPath)) { //copy the safetyFile copy($DFT_PATH_SAFETYFILE_TEMPLATE, $safetyFile); } $headers = array( "Content-type: Content-Type:application/json", "User-Agent: REEFTintegrationLog 1.0" ); $parms = '?' . 'input_string=' . $dirPath ; // Set URL $url = $DFT_WEBSERVICE_URL ."/delete_dir.php"; // Add parms $url = $url . $parms; // Data to send $data = array('input_string' => $dirPath); $jsonData = json_encode($data); // Create a new cURL resource $ch = curl_init($url); // Attach encoded JSON string to the POST fields curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); // Set the content type to application/json //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers ); // Return response instead of outputting curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, false); //curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); curl_setopt($ch, CURLOPT_HEADER, false); // we do not need headers curl_setopt($ch, CURLOPT_NOBODY, false); // we don't need body // Execute the GET request $result = curl_exec($ch); $ary = curl_getinfo($ch); // Close cURL resource curl_close($ch); $data = json_decode($result, true); if (isset($data["header"]["returnCode"]) && $data["header"]["returnCode"] == '00') { $sql = "DELETE FROM reeft_customer WHERE cust_number = '$cust_number_delete'"; } else { $sql = ""; $returnCode = $data["header"]["returnCode"]; $returnMsg = $data["header"]["returnMsg"]; } } //echo $sql; //====================================================================================== // Get data //====================================================================================== if ($sql != "") include "include/db_run_sql.php"; //====================================================================================== // Paint it black //====================================================================================== //====================================================================================== // Create header //====================================================================================== // Create header $aryHeader = array(); $aryHeader["mode"] = $mode; $aryHeader["returnCode"] = $returnCode; $aryHeader["returnMsg"] = $returnMsg; $aryHeader["entries_found"] = $entries_found; $aryHeader["currentDate"] = $currentDate; $aryHeader["currentTime"] = $currentTime; // Create array and prepare for json encoding $returnJson["header"] = $aryHeader; //====================================================================================== // Paint it black //====================================================================================== echo(json_encode($returnJson)); ?>